package cn.lg.soar.system.auth.controller;

import cn.lg.soar.common.model.HttpResult;
import cn.lg.soar.system.api.constant.ModuleConst;
import cn.lg.soar.system.auth.model.UserSelectorDTO;
import cn.lg.soar.system.auth.service.UserSelectorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author luguoxiang
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
@Validated
@Api(tags = "用户选择器")
@RestController
@RequestMapping(ModuleConst.MODULE_NAME + "/user-selector")
public class UserSelectorController {

    @Autowired
    private UserSelectorService userSelectorService;

    @ApiOperation("根据用户id")
    @GetMapping(value = "ids")
    public HttpResult<List<UserSelectorDTO>> ids(@RequestParam List<Long> ids){
        return HttpResult.data(userSelectorService.ids(ids));
    }

    @ApiOperation("关键字搜索")
    @GetMapping(value = "query")
    public HttpResult<List<UserSelectorDTO>> query(@RequestParam String keyword){
        return HttpResult.data(userSelectorService.query(keyword));
    }

    @ApiOperation("根据组织机构")
    @GetMapping(value = "org")
    public HttpResult<List<UserSelectorDTO>> org(@RequestParam Long parentId){
        return HttpResult.data(userSelectorService.org(parentId));
    }

    @ApiOperation("根据标签")
    @GetMapping(value = "tag")
    public HttpResult<List<UserSelectorDTO>> tag(@RequestParam Long tagId){
        return HttpResult.data(userSelectorService.tag(tagId));
    }

}
